package pers.vic.practice.module.system.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import pers.vic.boot.base.model.BaseResponse;
import pers.vic.boot.base.vo.Select2VO;
import pers.vic.practice.base.controller.BaseController;
import pers.vic.practice.module.system.service.SysDictTypeService;
import pers.vic.practice.module.system.model.SysDictType;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @description:字典类型表 控制层
 * @author Vic.xu
 * @date: 2022-04-12 09:48
 */
@RestController
@RequestMapping("/system/dictType")
public class SysDictTypeController extends BaseController {

    @Resource
    private SysDictTypeService sysDictTypeService;

    @RequestMapping("/all")
    public BaseResponse<?> all( SysDictType lookup){
        List<SysDictType> list = sysDictTypeService.list(lookup);
        List<Select2VO> voList = list.stream().map(d -> {
            return new Select2VO(d.getCode(), d.getName());
        }).collect(Collectors.toList());
        return BaseResponse.success(voList);
    }


}
